home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Add-Ons / After Dark / The Swarm 1.0 / Source (THINK C 6.0) / AfterDarkShell.c next >
Encoding:
C/C++ Source or Header  |  1994-03-08  |  2.5 KB  |  85 lines  |  [TEXT/R*ch]

  1. /*
  2.    GraphicsModule_main.c
  3.  
  4.    Apple and Think C Implementation of 'ADgm' screen saver code resource.
  5.  
  6.    This file provides a generic interface for writing a After Dark™ graphics module.
  7.    The function "main" is called by After Dark and passed four parameters:
  8.  
  9.    storage:     A Handle to memory you have allocated.
  10.    blankRgn:    A region covering all screens.
  11.    message:     A value indicating which function to call.
  12.    params:              A pointer to a structure containing useful information.
  13.  
  14.    To use it, write the five routines:
  15.  
  16.    OSErr DoInitialize(Handle *storage, RgnHandle blankRgn, GMParamBlockPtr params);
  17.    OSErr DoClose(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
  18.    OSErr DoBlank(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
  19.    OSErr DoDrawFrame(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
  20.  
  21.    For more information, consult the programmer's section of the manual.
  22.  
  23.    By Patrick Beard and Bruce Burkhalter and Colin Glassey
  24.  
  25.    ©1989,1990,1991 Berkeley Systems, Inc.
  26.  */
  27.  
  28. #include <QuickDraw.h>
  29. #include "AfterDarkTypes.h"
  30. #ifdef THINK_C
  31. /* allows use of Global vars with Think C */
  32. #include <SetUpA4.h>
  33. #define OpenGlobals()   RememberA0(); SetUpA4();
  34. #define CloseGlobals()  RestoreA4();
  35. #endif
  36.  
  37. /* entry point into graphics module */
  38.  
  39. pascal OSErr
  40. main(storage, blankRgn, message, params)
  41. Handle *storage;                /* storage allocated by graphics module. */
  42. RgnHandle blankRgn;             /* region to do all drawing in. */
  43. short message;                  /* the action to take */
  44. GMParamBlockPtr params;         /* parameters & services for controlling graphics module */
  45. {
  46.     OSErr err = noErr;
  47.  
  48. #ifdef THINK_C
  49.     /* set up globals for strings etc. only for THINK C */
  50.     OpenGlobals();
  51. #endif
  52.     /* dispatch message to appropriate routine. */
  53.     switch (message)
  54.     {
  55.     case Initialize:
  56.         err = DoInitialize(storage, blankRgn, params);
  57.         break;
  58.     case Close:
  59.         err = DoClose(*storage, blankRgn, params);
  60.         break;
  61.     case Blank:
  62.         err = DoBlank(*storage, blankRgn, params);
  63.         break;
  64.     case DrawFrame:
  65.         err = DoDrawFrame(*storage, blankRgn, params);
  66.         break;
  67.     case DoAbout:
  68.         err = DoHelp(blankRgn, params);
  69.         break;
  70.         
  71.         /* Not handled by our module.
  72.     case ModuleSelected:
  73.         err = DoSelected(params);
  74.         break;
  75.         */
  76.  
  77.     default:
  78.         break;
  79.     }                           /* end switch */
  80. #ifdef THINK_C
  81.     CloseGlobals();
  82. #endif
  83.     return err;
  84. }
  85.